home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
4_8.lha
/
4_8
/
4_8b.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
607b
|
36 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <stack.h>
include <error.h>
/ add a value to a stack
oid push(stack *s, stacktype c)
if (s->curtop < s->maxsize)
s->mem[s->curtop++] = c;
else
error("stack overflow");
/ return and remove top of stack
tacktype pop(stack *s)
if (s->curtop > 0)
return s->mem[--s->curtop];
else
error("stack underflow");
/ return top of stack
tacktype top(stack *s)
if (s->curtop > 0)
return s->mem[s->curtop - 1];
else
error("stack underflow");